package com.jqb.webservice.service.impl;

import java.util.ArrayList;
import java.util.List;

import javax.jws.HandlerChain;
import javax.jws.WebService;

import com.jqb.webservice.vo.User;
import com.jqb.webservice.vo.UserException;
@HandlerChain(file="licencehandler-chain.xml")
@WebService(endpointInterface = "com.jqb.webservice.service.impl.MixService")
public class MixServiceImpl implements MixService {
	List<User> users = new ArrayList<User>();
	public MixServiceImpl(){
		User user = new User(1000,"admin","admin123");
		users.add(user);
	}
	@Override
	public int add(int a, int b) {
		return a+b;
	}

	@Override
	public User addUser(User user) {
		users.add(user);
		return user;
	}

	@Override
	public User login(String username, String password) throws UserException {
		for(User user:users){
			if((username.equals(user.getUsername()))&&(password.equals(user.getPassword()))){
				return user;
			}
		}
		throw new UserException("用户名或密码错误...");
	}

	@Override
	public List<User> getUsers() {
		return users;
	}

}
